#include <iostream>
#include <noise.h>

#include "noiseutils.h"
#include "..\Chunk.h"

using namespace noise;

#define SAMPLE_RATE_3D_HOR	4
#define SAMPLE_RATE_3D_VERT	4

class Landmap
{
private:
	int	  _x;
	int	  _z;

	module::Perlin				pGen0, pGen1, pGen2, pGen3, pGen4, pGen5;
	module::RidgedMulti			pGen6;

	void init(int seed, int octaves, int x, int z);
private:
	double calcDensity(int x, int y, int z, Biomemap * pBiome);
	double calcBaseTerrain(double x, double z);
	double calcOceanTerrain(double x, double z);
	double calcRiverTerrain(double x, double z);
	double calcMountainDensity(double x, double y, double z);
	double calcHillDensity(double x, double y, double z);
	double calcCaveDensity(int x, int y, int z);

	void triLerpDensityMap(double* densityMap);
	void GenerateInnerLayer(int x, int y, int z, Block &mem, BYTE type);
	void GenerateOuterLayer(int x, int y, int z, int firstBlockHeight, Block &mem, BYTE type) ;
public:
	Landmap(int seed, int octaves, int x, int z);
	Landmap(int seed, int x, int z);
	Landmap(int x, int z);
	~Landmap();

	void generateChunk(int rx, int rz, Chunk ** pChunks, Biomemap * pBiome);
};